package com.seqb.common;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lilinshen
 * @title 返回结果的VO对象
 * @description 请填写相关描述
 * @date 2019/11/11
 */
public class ResultVo extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public ResultVo() {
        put("code", 0);
        put("msg", "操作成功");
    }

    public static ResultVo error() {
        return error(1, "操作失败");
    }

    public static ResultVo error(String msg) {
        return error(500, msg);
    }

    public static ResultVo error(int code, String msg) {
        ResultVo r = new ResultVo();
        r.put("code", code);
        r.put("msg", msg);
        return r;
    }

    public static ResultVo ok(String msg) {
        ResultVo r = new ResultVo();
        r.put("msg", msg);
        return r;
    }

    public static ResultVo ok(Map<String, Object> map) {
        ResultVo r = new ResultVo();
        r.putAll(map);
        return r;
    }

    public static ResultVo ok() {
        return new ResultVo();
    }

    public ResultVo put(String key, Object value) {
        super.put(key, value);
        return this;
    }

    @Override
    public String toString() {
        return super.toString();
    }
}
